package com.yxt.common.ui;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class TextItemOnClickListener implements OnClickListener {
	private Context context;
	private Class toClass;
	private Map<String,String> parameters = new HashMap<String,String>();
	
	public TextItemOnClickListener(Context context, Class toClass) {
		super();
		this.context = context;
		this.toClass = toClass;
	}
	
	public TextItemOnClickListener(Context context, Class toClass,Map<String,String> params) {
		super();
		this.context = context;
		this.toClass = toClass;
		this.parameters = params;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	public Class getToClass() {
		return toClass;
	}

	public void setToClass(Class toClass) {
		this.toClass = toClass;
	}

	public Map<String, String> getParameters() {
		return parameters;
	}

	public void setParameters(Map<String, String> parameters) {
		this.parameters = parameters;
	}

	public void onClick(View arg0) {
		Intent intent = new Intent();
		intent.setClass(context, toClass);
		Iterator<Entry<String,String>> iterator = parameters.entrySet().iterator();
		while(iterator.hasNext()) {
			Entry<String,String> entry = iterator.next();
			intent.putExtra(entry.getKey(), entry.getValue());
		}
		context.startActivity(intent);
	}
}